(function () {
  var tbody = document.querySelector('table tbody');
  var checkAll = document.querySelector('thead tr th input');

  function init() {
    var sHtml = '';
    for (var i = 0; i < peoples.length; i++) {
      var item = peoples[i];
      sHtml += `
        <tr>
        <td><input type="checkbox" ${item.isselect}/></td>
        <td>${item.id}</td>
        <td>${item.name}</td>
        <td>${item.age}</td>
        <td>${item.job}</td>
      </tr>`;
    }
    tbody.innerHTML += sHtml;

    checkAll.addEventListener('click', controlAll);
  }

  function controlAll() {
    var checkboxs = document.querySelectorAll('tbody tr td:first-child input');
    for (var i = 0; i < checkboxs.length; i++) {
      var checkbox = checkboxs[i];
      checkbox.checked = checkAll.checked;
    }
  }

  init();
})();
